package example1;

import org.apache.commons.collections4.ListUtils;
import org.apache.commons.io.FileUtils;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

public class ShowByte {
    static String ORG_PATH = "D:/TEMP/20220618015052.png";

    @Test
    public void t1() throws Exception {
        byte[] bytes = FileUtils.readFileToByteArray(FileUtils.getFile(ORG_PATH));

        byte[] copyOf = Arrays.copyOf(bytes, 512);

        Thread.sleep(5 * 1000);

        String[] hexArray = HexUtil.byteToHexStringArray(bytes);

        List<String> hexList = Arrays.asList(hexArray);
        List<List<String>> partition = ListUtils.partition(hexList, 16);
        for (List<String> list : partition) {
            String join = String.join("", list);
            System.out.println(join);
        }
    }

    @Test
    public void t2() throws Exception {
        String filePath = "C:/Users/yangyang/Desktop/dist.zip";
        byte[] bytes = FileUtils.readFileToByteArray(FileUtils.getFile(filePath));

        String[] hexArray = HexUtil.byteToHexStringArray(bytes);

        HexUtil.writeHexArrToFile(hexArray,"C:/Users/yangyang/Desktop/viewHex.txt");
    }

}
